//BeanCipher - Bean Cipher Security Layer
//Copyright (C) 2005 Raul Alfredo Bajales
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package ar.com.rab.beancipher.impl.configuration;

import java.lang.reflect.Method;

import ar.com.rab.beancipher.spi.IPropertyDescriptor;


/**
 * Implementation of <code>IPropertyDescriptor</code> interface.
 * 
 * @see ar.com.rab.beancipher.spi.IPropertyDescriptor
 * @author Bajales Raul
 *
 */
public class PropertyDescriptor implements IPropertyDescriptor {
    
    private String propertyName;
    private String className;
    private Method setter;
    private Method getter;
    
    /**
     * @param propertyName
     * @param className
     * @param setter
     * @param getter
     */
    public PropertyDescriptor(String propertyName, String className, Method setter, Method getter) {
        super();
        this.propertyName = propertyName;
        this.className = className;
        this.setter = setter;
        this.getter = getter;
    }
    /**
     * @return Returns the className.
     */
    public String getClassName() {
        return className;
    }
    /**
     * @param className The className to set.
     */
    public void setClassName(String className) {
        this.className = className;
    }
    /**
     * @return Returns the getter.
     */
    public Method getGetter() {
        return getter;
    }
    /**
     * @param getter The getter to set.
     */
    public void setGetter(Method getter) {
        this.getter = getter;
    }
    /**
     * @return Returns the propertyName.
     */
    public String getPropertyName() {
        return propertyName;
    }
    /**
     * @param propertyName The propertyName to set.
     */
    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }
    /**
     * @return Returns the setter.
     */
    public Method getSetter() {
        return setter;
    }
    /**
     * @param setter The setter to set.
     */
    public void setSetter(Method setter) {
        this.setter = setter;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj) {
        if (!(obj instanceof IPropertyDescriptor)) return false;
        return this.propertyName.equals(((IPropertyDescriptor) obj).getPropertyName());
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return this.propertyName.hashCode();
    }
}